/*     */ package com.zimbra.cs.store;
/*     */ 
/*     */ import com.zimbra.common.localconfig.KnownKey;
/*     */ import com.zimbra.common.localconfig.LC;
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.ZimbraLog;
/*     */ import com.zimbra.cs.account.Provisioning;
/*     */ import com.zimbra.cs.account.Server;
/*     */ import com.zimbra.cs.extension.ExtensionUtil;
/*     */ import com.zimbra.cs.mailbox.MailItem;
/*     */ import com.zimbra.cs.mailbox.Mailbox;
/*     */ import com.zimbra.cs.store.file.FileBlobStore;
/*     */ import com.zimbra.cs.util.Zimbra;
/*     */ import java.io.IOException;
/*     */ import java.io.InputStream;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public abstract class StoreManager
/*     */ {
/*     */   private static StoreManager sInstance;
/*     */   private static Integer diskStreamingThreshold;
/*     */   
/*     */   public static StoreManager getInstance()
/*     */   {
/*  38 */     if (sInstance == null) {
/*  39 */       synchronized (StoreManager.class) {
/*  40 */         if (sInstance != null) {
/*  41 */           return sInstance;
/*     */         }
/*     */         
/*  44 */         String className = LC.zimbra_class_store.value();
/*     */         try {
/*  46 */           if ((className != null) && (!className.equals(""))) {
/*     */             try {
/*  48 */               sInstance = (StoreManager)Class.forName(className).newInstance();
/*     */             } catch (ClassNotFoundException e) {
/*  50 */               sInstance = (StoreManager)ExtensionUtil.findClass(className).newInstance();
/*     */             }
/*     */           } else {
/*  53 */             sInstance = new FileBlobStore();
/*     */           }
/*     */         } catch (Throwable t) {
/*  56 */           Zimbra.halt("unable to initialize blob store", t);
/*     */         }
/*     */       }
/*     */     }
/*  60 */     return sInstance;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public static void setInstance(StoreManager instance)
/*     */   {
/*  67 */     ZimbraLog.store.info("Setting StoreManager to " + instance.getClass().getName());
/*  68 */     sInstance = instance;
/*     */   }
/*     */   
/*     */   public static int getDiskStreamingThreshold()
/*     */     throws ServiceException
/*     */   {
/*  74 */     if (diskStreamingThreshold == null)
/*  75 */       loadSettings();
/*  76 */     return diskStreamingThreshold.intValue();
/*     */   }
/*     */   
/*     */   public static void loadSettings() throws ServiceException {
/*  80 */     Server server = Provisioning.getInstance().getLocalServer();
/*  81 */     diskStreamingThreshold = Integer.valueOf(server.getMailDiskStreamingThreshold());
/*     */   }
/*     */   
/*     */ 
/*     */   public abstract void startup()
/*     */     throws IOException, ServiceException;
/*     */   
/*     */ 
/*     */   public abstract void shutdown();
/*     */   
/*     */   public abstract boolean supports(StoreFeature paramStoreFeature);
/*     */   
/*     */   public abstract BlobBuilder getBlobBuilder()
/*     */     throws IOException, ServiceException;
/*     */   
/*     */   public static enum StoreFeature
/*     */   {
/*  98 */     BULK_DELETE, 
/*     */     
/*     */ 
/*     */ 
/* 102 */     CENTRALIZED, 
/*     */     
/*     */ 
/*     */ 
/* 106 */     RESUMABLE_UPLOAD, 
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 113 */     SINGLE_INSTANCE_SERVER_CREATE;
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */     private StoreFeature() {}
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public Blob storeIncoming(InputStream data)
/*     */     throws IOException, ServiceException
/*     */   {
/* 145 */     return storeIncoming(data, false);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public abstract Blob storeIncoming(InputStream paramInputStream, boolean paramBoolean)
/*     */     throws IOException, ServiceException;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public abstract StagedBlob stage(InputStream paramInputStream, long paramLong, Mailbox paramMailbox)
/*     */     throws IOException, ServiceException;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public StagedBlob stage(InputStream data, Mailbox mbox)
/*     */     throws IOException, ServiceException
/*     */   {
/* 184 */     return stage(data, -1L, mbox);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public abstract StagedBlob stage(Blob paramBlob, Mailbox paramMailbox)
/*     */     throws IOException, ServiceException;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public abstract MailboxBlob copy(MailboxBlob paramMailboxBlob, Mailbox paramMailbox, int paramInt1, int paramInt2)
/*     */     throws IOException, ServiceException;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public abstract MailboxBlob link(StagedBlob paramStagedBlob, Mailbox paramMailbox, int paramInt1, int paramInt2)
/*     */     throws IOException, ServiceException;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public abstract MailboxBlob renameTo(StagedBlob paramStagedBlob, Mailbox paramMailbox, int paramInt1, int paramInt2)
/*     */     throws IOException, ServiceException;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public abstract boolean delete(Blob paramBlob)
/*     */     throws IOException;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public boolean quietDelete(Blob blob)
/*     */   {
/* 260 */     if (blob == null) {
/* 261 */       return true;
/*     */     }
/*     */     try
/*     */     {
/* 265 */       return delete(blob);
/*     */     } catch (IOException ioe) {
/* 267 */       ZimbraLog.store.warn("could not delete blob " + blob.getPath()); }
/* 268 */     return false;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public abstract boolean delete(StagedBlob paramStagedBlob)
/*     */     throws IOException;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public boolean quietDelete(StagedBlob staged)
/*     */   {
/* 288 */     if (staged == null) {
/* 289 */       return true;
/*     */     }
/*     */     try
/*     */     {
/* 293 */       return delete(staged);
/*     */     } catch (IOException ioe) {
/* 295 */       ZimbraLog.store.warn("could not delete staged blob " + staged); }
/* 296 */     return false;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public abstract boolean delete(MailboxBlob paramMailboxBlob)
/*     */     throws IOException;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public boolean quietDelete(MailboxBlob mblob)
/*     */   {
/* 316 */     if (mblob == null) {
/* 317 */       return true;
/*     */     }
/*     */     try
/*     */     {
/* 321 */       return delete(mblob);
/*     */     } catch (IOException ioe) {
/* 323 */       ZimbraLog.store.warn("could not delete blob " + mblob); }
/* 324 */     return false;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public abstract MailboxBlob getMailboxBlob(Mailbox paramMailbox, int paramInt1, int paramInt2, String paramString)
/*     */     throws ServiceException;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public MailboxBlob getMailboxBlob(MailItem item)
/*     */     throws ServiceException
/*     */   {
/* 350 */     MailboxBlob mblob = getMailboxBlob(item.getMailbox(), item.getId(), item.getSavedSequence(), item.getLocator());
/* 351 */     if (mblob != null) {
/* 352 */       mblob.setDigest(item.getDigest()).setSize(item.getSize());
/*     */     }
/* 354 */     return mblob;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public abstract InputStream getContent(MailboxBlob paramMailboxBlob)
/*     */     throws IOException;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public abstract InputStream getContent(Blob paramBlob)
/*     */     throws IOException;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public abstract boolean deleteStore(Mailbox paramMailbox, Iterable<MailboxBlob.MailboxBlobInfo> paramIterable)
/*     */     throws IOException, ServiceException;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public IncomingBlob newIncomingBlob(String id, Object ctxt)
/*     */     throws IOException, ServiceException
/*     */   {
/* 397 */     return new BufferingIncomingBlob(id, getBlobBuilder(), ctxt);
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/store/StoreManager.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */